package org.erepublik.company.product;

import org.erepublik.company.ECountry;

/**
 * Klasa pomocnicza przy hashowaniu firm
 *
 * @author Kacper Gorski 'Railman' railman85@gmail.com
 */
public class ProductKey {

	private int companyID;
	private ECountry market;
	
	public ProductKey(int companyID, ECountry market) {
		this.companyID = companyID;
		this.market = market;
	}
	
	public int getCompanyID() {
		return companyID;
	}
	public void setCompanyID(int companyID) {
		this.companyID = companyID;
	}
	public ECountry getMarket() {
		return market;
	}
	public void setMarket(ECountry market) {
		this.market = market;
	}
	
	@Override
	public int hashCode() {
		return companyID * (market.ordinal()+752);
	}
	
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof ProductKey) {
			ProductKey otherProduct = (ProductKey)obj;
			return getCompanyID() == otherProduct.getCompanyID()
				&& getMarket() == otherProduct.getMarket();
		}
		else
			return false;
	}
	
}
